<?php
/**
*	@author SignpostMarv Martin
*	@package LLSD
*/

/**
*	The class used to represent UUID LLSD nodes- allows a native PHP data type to hold UUID elements in order to differentiate them from normal strings
*	@package LLSD
*/
class uhu_LLSD_UUID extends uhu_LLSD_common
{
/**
*	@var string The UUID in question.
*/
	protected $uuid;
/**
*	Builds an instance of uhu_LLSD_UUID
*	@param string|SimpleXMLElement The UUID string or node
*	@uses uhu_LLSD_UUID::$uuid
*	@uses is_uuid
*	@uses uhu_LLSD_exception
*/
	public function __construct($uuid)
	{
		if($uuid instanceof SimpleXMLElement)
		{
			$uuid = (string)$uuid;
		}
		if(empty($uuid))
		{
			$uuid = NULL_KEY;
		}
		if(is_uuid($uuid) === false)
		{
			throw new uhu_LLSD_exception('Value given not a UUID.',103);
		}
		else
		{
			$this->uuid = $uuid;
		}
	}
/**
*	@return string the UUID supplied to uhu_LLSD_UUID::__construct(), or NULL_KEY when appropriate.
*/
	public function __toString()
	{
		return $this->uuid;
	}
}
?>